package Frame.screen;

import FCRendering.FCRConstants;
import FCRendering.FCRMaster;
import FCRendering.ImageUtil;
import Function.Utils.SwingUtil;

import java.awt.*;

import static FCRendering.FCRMaster.fcv;

public class DefaultMessageScreen extends IScreen{
    Font font, font2;
    @Override
    public void dispatchPaintComponent(Graphics g, FCRMaster fcrMaster) {
        // 消息
        if (fcv.getMessageShowNum() > 0&& fcv.getMessage().size() > 0) {
            g.setFont(font2);
            g.setColor(Color.WHITE);

            for (int i = 1; i < 8; i++) {//背景
                if (i <= fcv.getMessage().size()) {
                    int len = SwingUtil.getStringWidht(fcv.getMessage().get(fcv.getMessage().size() - i),font2)+(int) (70 * fcv.getProportion());
                    g.drawImage(ImageUtil.getImage("battleBG"), (int) (5 * fcv.getProportion()),
                            (int) (fcrMaster.getHeight() - 8 * fcv.getProportion() - 27 * (i) * fcv.getProportion()),len,(int) (40 * fcv.getProportion()), this);
                } else
                    break;
            }
            for (int i = 1; i < 8; i++) {//文字
                if (i <= fcv.getMessage().size()) {
                    g.drawString(fcv.getMessage().get(fcv.getMessage().size() - i), (int) (10 * fcv.getProportion()),
                            (int) (fcrMaster.getHeight() - 5 * fcv.getProportion() - 29 * (i-1) * fcv.getProportion()));
                } else
                    break;
            }
            if(!fcv.isBattle()) {
                fcv.setMessageShowNum(fcv.getMessageShowNum() - 1);
            }
        }
    }

    @Override
    public void setBounds() {
        font = new Font(FCRConstants.FONT_BLACK, 1, (int) (24 * fcv.getProportion()));
        font2 = new Font(FCRConstants.FONT_BLACK, 1, (int) (26 * fcv.getProportion()));
    }
}
